
user/_pingpong:     file format elf64-littleriscv


Disassembly of section .text:

0000000000000000 <main>:
#include "user/user.h"

#include <stdarg.h>

int main(int argc, char* argv[])
{
   0:	7139                	addi	sp,sp,-64
   2:	fc06                	sd	ra,56(sp)
   4:	f822                	sd	s0,48(sp)
   6:	f426                	sd	s1,40(sp)
   8:	0080                	addi	s0,sp,64
	if (argc > 1) fprintf(2,"it's no need to enter param\n");
   a:	4785                	li	a5,1
   c:	04a7c163          	blt	a5,a0,4e <main+0x4e>
	int pipe_fdp[2];
	//管道2，数据从子进程流向父进程，0为读端，1为写端
	int pipe_fdc[2];
	
	//创建管道
	if (pipe(pipe_fdp) == -1 || pipe(pipe_fdc) == -1)
  10:	fd840513          	addi	a0,s0,-40
  14:	00000097          	auipc	ra,0x0
  18:	456080e7          	jalr	1110(ra) # 46a <pipe>
  1c:	57fd                	li	a5,-1
  1e:	00f50b63          	beq	a0,a5,34 <main+0x34>
  22:	fd040513          	addi	a0,s0,-48
  26:	00000097          	auipc	ra,0x0
  2a:	444080e7          	jalr	1092(ra) # 46a <pipe>
  2e:	57fd                	li	a5,-1
  30:	02f51963          	bne	a0,a5,62 <main+0x62>
	{
		printf("pipe error");
  34:	00001517          	auipc	a0,0x1
  38:	96450513          	addi	a0,a0,-1692 # 998 <malloc+0x108>
  3c:	00000097          	auipc	ra,0x0
  40:	796080e7          	jalr	1942(ra) # 7d2 <printf>
		exit(1);
  44:	4505                	li	a0,1
  46:	00000097          	auipc	ra,0x0
  4a:	414080e7          	jalr	1044(ra) # 45a <exit>
	if (argc > 1) fprintf(2,"it's no need to enter param\n");
  4e:	00001597          	auipc	a1,0x1
  52:	92a58593          	addi	a1,a1,-1750 # 978 <malloc+0xe8>
  56:	4509                	li	a0,2
  58:	00000097          	auipc	ra,0x0
  5c:	74c080e7          	jalr	1868(ra) # 7a4 <fprintf>
  60:	bf45                	j	10 <main+0x10>
	}
	
	int pid = fork(); //子进程继承父进程，从此开始
  62:	00000097          	auipc	ra,0x0
  66:	3f0080e7          	jalr	1008(ra) # 452 <fork>

	if (pid == -1)
  6a:	57fd                	li	a5,-1
  6c:	08f50f63          	beq	a0,a5,10a <main+0x10a>
	{
		printf("fork error");
		exit(1);
	}

	if (pid == 0)
  70:	e961                	bnez	a0,140 <main+0x140>
	{
		//紫禁城

		//管道是单通的，关闭不用的端口防止阻塞
		close(pipe_fdp[1]);
  72:	fdc42503          	lw	a0,-36(s0)
  76:	00000097          	auipc	ra,0x0
  7a:	40c080e7          	jalr	1036(ra) # 482 <close>
		close(pipe_fdc[0]);
  7e:	fd042503          	lw	a0,-48(s0)
  82:	00000097          	auipc	ra,0x0
  86:	400080e7          	jalr	1024(ra) # 482 <close>
		
		int cid = getpid();
  8a:	00000097          	auipc	ra,0x0
  8e:	450080e7          	jalr	1104(ra) # 4da <getpid>
  92:	84aa                	mv	s1,a0
		char buff[1];
		if( read(pipe_fdp[0], buff, sizeof(buff)) >= 1 )
  94:	4605                	li	a2,1
  96:	fc840593          	addi	a1,s0,-56
  9a:	fd842503          	lw	a0,-40(s0)
  9e:	00000097          	auipc	ra,0x0
  a2:	3d4080e7          	jalr	980(ra) # 472 <read>
  a6:	06a05f63          	blez	a0,124 <main+0x124>
		{
			fprintf(2, "%d: received ping\n", cid);
  aa:	8626                	mv	a2,s1
  ac:	00001597          	auipc	a1,0x1
  b0:	90c58593          	addi	a1,a1,-1780 # 9b8 <malloc+0x128>
  b4:	4509                	li	a0,2
  b6:	00000097          	auipc	ra,0x0
  ba:	6ee080e7          	jalr	1774(ra) # 7a4 <fprintf>

			char *msgc = "y";
			write(pipe_fdc[1], msgc, strlen(msgc) + 1);
  be:	fd442483          	lw	s1,-44(s0)
  c2:	00001517          	auipc	a0,0x1
  c6:	90e50513          	addi	a0,a0,-1778 # 9d0 <malloc+0x140>
  ca:	00000097          	auipc	ra,0x0
  ce:	162080e7          	jalr	354(ra) # 22c <strlen>
  d2:	0015061b          	addiw	a2,a0,1
  d6:	00001597          	auipc	a1,0x1
  da:	8fa58593          	addi	a1,a1,-1798 # 9d0 <malloc+0x140>
  de:	8526                	mv	a0,s1
  e0:	00000097          	auipc	ra,0x0
  e4:	39a080e7          	jalr	922(ra) # 47a <write>
		else {
			fprintf(2, "error child read...");
			exit(1);
		}

		close(pipe_fdp[0]);
  e8:	fd842503          	lw	a0,-40(s0)
  ec:	00000097          	auipc	ra,0x0
  f0:	396080e7          	jalr	918(ra) # 482 <close>
		close(pipe_fdc[1]);
  f4:	fd442503          	lw	a0,-44(s0)
  f8:	00000097          	auipc	ra,0x0
  fc:	38a080e7          	jalr	906(ra) # 482 <close>

		exit(0);
 100:	4501                	li	a0,0
 102:	00000097          	auipc	ra,0x0
 106:	358080e7          	jalr	856(ra) # 45a <exit>
		printf("fork error");
 10a:	00001517          	auipc	a0,0x1
 10e:	89e50513          	addi	a0,a0,-1890 # 9a8 <malloc+0x118>
 112:	00000097          	auipc	ra,0x0
 116:	6c0080e7          	jalr	1728(ra) # 7d2 <printf>
		exit(1);
 11a:	4505                	li	a0,1
 11c:	00000097          	auipc	ra,0x0
 120:	33e080e7          	jalr	830(ra) # 45a <exit>
			fprintf(2, "error child read...");
 124:	00001597          	auipc	a1,0x1
 128:	8b458593          	addi	a1,a1,-1868 # 9d8 <malloc+0x148>
 12c:	4509                	li	a0,2
 12e:	00000097          	auipc	ra,0x0
 132:	676080e7          	jalr	1654(ra) # 7a4 <fprintf>
			exit(1);
 136:	4505                	li	a0,1
 138:	00000097          	auipc	ra,0x0
 13c:	322080e7          	jalr	802(ra) # 45a <exit>
	}

	else 
	{
		//父进程
		close(pipe_fdp[0]);
 140:	fd842503          	lw	a0,-40(s0)
 144:	00000097          	auipc	ra,0x0
 148:	33e080e7          	jalr	830(ra) # 482 <close>
		close(pipe_fdc[1]);
 14c:	fd442503          	lw	a0,-44(s0)
 150:	00000097          	auipc	ra,0x0
 154:	332080e7          	jalr	818(ra) # 482 <close>

		char* msgp = "y";
		write(pipe_fdp[1], msgp, strlen(msgp) + 1);
 158:	fdc42483          	lw	s1,-36(s0)
 15c:	00001517          	auipc	a0,0x1
 160:	87450513          	addi	a0,a0,-1932 # 9d0 <malloc+0x140>
 164:	00000097          	auipc	ra,0x0
 168:	0c8080e7          	jalr	200(ra) # 22c <strlen>
 16c:	0015061b          	addiw	a2,a0,1
 170:	00001597          	auipc	a1,0x1
 174:	86058593          	addi	a1,a1,-1952 # 9d0 <malloc+0x140>
 178:	8526                	mv	a0,s1
 17a:	00000097          	auipc	ra,0x0
 17e:	300080e7          	jalr	768(ra) # 47a <write>
		
		int fid = getpid();
 182:	00000097          	auipc	ra,0x0
 186:	358080e7          	jalr	856(ra) # 4da <getpid>
 18a:	84aa                	mv	s1,a0
		char buf[1];
		if (read(pipe_fdc[0], buf, sizeof(buf)) >= 1)
 18c:	4605                	li	a2,1
 18e:	fc840593          	addi	a1,s0,-56
 192:	fd042503          	lw	a0,-48(s0)
 196:	00000097          	auipc	ra,0x0
 19a:	2dc080e7          	jalr	732(ra) # 472 <read>
 19e:	02a04863          	bgtz	a0,1ce <main+0x1ce>
		{
			fprintf(2, "%d: received pong\n", fid);
		}

		close(pipe_fdp[1]);
 1a2:	fdc42503          	lw	a0,-36(s0)
 1a6:	00000097          	auipc	ra,0x0
 1aa:	2dc080e7          	jalr	732(ra) # 482 <close>
		close(pipe_fdc[0]);
 1ae:	fd042503          	lw	a0,-48(s0)
 1b2:	00000097          	auipc	ra,0x0
 1b6:	2d0080e7          	jalr	720(ra) # 482 <close>
		
		wait((int*)0); //等待子进程结束
 1ba:	4501                	li	a0,0
 1bc:	00000097          	auipc	ra,0x0
 1c0:	2a6080e7          	jalr	678(ra) # 462 <wait>
		exit(0);
 1c4:	4501                	li	a0,0
 1c6:	00000097          	auipc	ra,0x0
 1ca:	294080e7          	jalr	660(ra) # 45a <exit>
			fprintf(2, "%d: received pong\n", fid);
 1ce:	8626                	mv	a2,s1
 1d0:	00001597          	auipc	a1,0x1
 1d4:	82058593          	addi	a1,a1,-2016 # 9f0 <malloc+0x160>
 1d8:	4509                	li	a0,2
 1da:	00000097          	auipc	ra,0x0
 1de:	5ca080e7          	jalr	1482(ra) # 7a4 <fprintf>
 1e2:	b7c1                	j	1a2 <main+0x1a2>

00000000000001e4 <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"

char*
strcpy(char *s, const char *t)
{
 1e4:	1141                	addi	sp,sp,-16
 1e6:	e422                	sd	s0,8(sp)
 1e8:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 1ea:	87aa                	mv	a5,a0
 1ec:	0585                	addi	a1,a1,1
 1ee:	0785                	addi	a5,a5,1
 1f0:	fff5c703          	lbu	a4,-1(a1)
 1f4:	fee78fa3          	sb	a4,-1(a5)
 1f8:	fb75                	bnez	a4,1ec <strcpy+0x8>
    ;
  return os;
}
 1fa:	6422                	ld	s0,8(sp)
 1fc:	0141                	addi	sp,sp,16
 1fe:	8082                	ret

0000000000000200 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 200:	1141                	addi	sp,sp,-16
 202:	e422                	sd	s0,8(sp)
 204:	0800                	addi	s0,sp,16
  while(*p && *p == *q)
 206:	00054783          	lbu	a5,0(a0)
 20a:	cb91                	beqz	a5,21e <strcmp+0x1e>
 20c:	0005c703          	lbu	a4,0(a1)
 210:	00f71763          	bne	a4,a5,21e <strcmp+0x1e>
    p++, q++;
 214:	0505                	addi	a0,a0,1
 216:	0585                	addi	a1,a1,1
  while(*p && *p == *q)
 218:	00054783          	lbu	a5,0(a0)
 21c:	fbe5                	bnez	a5,20c <strcmp+0xc>
  return (uchar)*p - (uchar)*q;
 21e:	0005c503          	lbu	a0,0(a1)
}
 222:	40a7853b          	subw	a0,a5,a0
 226:	6422                	ld	s0,8(sp)
 228:	0141                	addi	sp,sp,16
 22a:	8082                	ret

000000000000022c <strlen>:

uint
strlen(const char *s)
{
 22c:	1141                	addi	sp,sp,-16
 22e:	e422                	sd	s0,8(sp)
 230:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
 232:	00054783          	lbu	a5,0(a0)
 236:	cf91                	beqz	a5,252 <strlen+0x26>
 238:	0505                	addi	a0,a0,1
 23a:	87aa                	mv	a5,a0
 23c:	4685                	li	a3,1
 23e:	9e89                	subw	a3,a3,a0
 240:	00f6853b          	addw	a0,a3,a5
 244:	0785                	addi	a5,a5,1
 246:	fff7c703          	lbu	a4,-1(a5)
 24a:	fb7d                	bnez	a4,240 <strlen+0x14>
    ;
  return n;
}
 24c:	6422                	ld	s0,8(sp)
 24e:	0141                	addi	sp,sp,16
 250:	8082                	ret
  for(n = 0; s[n]; n++)
 252:	4501                	li	a0,0
 254:	bfe5                	j	24c <strlen+0x20>

0000000000000256 <memset>:

void*
memset(void *dst, int c, uint n)
{
 256:	1141                	addi	sp,sp,-16
 258:	e422                	sd	s0,8(sp)
 25a:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
 25c:	ce09                	beqz	a2,276 <memset+0x20>
 25e:	87aa                	mv	a5,a0
 260:	fff6071b          	addiw	a4,a2,-1
 264:	1702                	slli	a4,a4,0x20
 266:	9301                	srli	a4,a4,0x20
 268:	0705                	addi	a4,a4,1
 26a:	972a                	add	a4,a4,a0
    cdst[i] = c;
 26c:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
 270:	0785                	addi	a5,a5,1
 272:	fee79de3          	bne	a5,a4,26c <memset+0x16>
  }
  return dst;
}
 276:	6422                	ld	s0,8(sp)
 278:	0141                	addi	sp,sp,16
 27a:	8082                	ret

000000000000027c <strchr>:

char*
strchr(const char *s, char c)
{
 27c:	1141                	addi	sp,sp,-16
 27e:	e422                	sd	s0,8(sp)
 280:	0800                	addi	s0,sp,16
  for(; *s; s++)
 282:	00054783          	lbu	a5,0(a0)
 286:	cb99                	beqz	a5,29c <strchr+0x20>
    if(*s == c)
 288:	00f58763          	beq	a1,a5,296 <strchr+0x1a>
  for(; *s; s++)
 28c:	0505                	addi	a0,a0,1
 28e:	00054783          	lbu	a5,0(a0)
 292:	fbfd                	bnez	a5,288 <strchr+0xc>
      return (char*)s;
  return 0;
 294:	4501                	li	a0,0
}
 296:	6422                	ld	s0,8(sp)
 298:	0141                	addi	sp,sp,16
 29a:	8082                	ret
  return 0;
 29c:	4501                	li	a0,0
 29e:	bfe5                	j	296 <strchr+0x1a>

00000000000002a0 <gets>:

char*
gets(char *buf, int max)
{
 2a0:	711d                	addi	sp,sp,-96
 2a2:	ec86                	sd	ra,88(sp)
 2a4:	e8a2                	sd	s0,80(sp)
 2a6:	e4a6                	sd	s1,72(sp)
 2a8:	e0ca                	sd	s2,64(sp)
 2aa:	fc4e                	sd	s3,56(sp)
 2ac:	f852                	sd	s4,48(sp)
 2ae:	f456                	sd	s5,40(sp)
 2b0:	f05a                	sd	s6,32(sp)
 2b2:	ec5e                	sd	s7,24(sp)
 2b4:	1080                	addi	s0,sp,96
 2b6:	8baa                	mv	s7,a0
 2b8:	8a2e                	mv	s4,a1
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 2ba:	892a                	mv	s2,a0
 2bc:	4481                	li	s1,0
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 2be:	4aa9                	li	s5,10
 2c0:	4b35                	li	s6,13
  for(i=0; i+1 < max; ){
 2c2:	89a6                	mv	s3,s1
 2c4:	2485                	addiw	s1,s1,1
 2c6:	0344d863          	bge	s1,s4,2f6 <gets+0x56>
    cc = read(0, &c, 1);
 2ca:	4605                	li	a2,1
 2cc:	faf40593          	addi	a1,s0,-81
 2d0:	4501                	li	a0,0
 2d2:	00000097          	auipc	ra,0x0
 2d6:	1a0080e7          	jalr	416(ra) # 472 <read>
    if(cc < 1)
 2da:	00a05e63          	blez	a0,2f6 <gets+0x56>
    buf[i++] = c;
 2de:	faf44783          	lbu	a5,-81(s0)
 2e2:	00f90023          	sb	a5,0(s2)
    if(c == '\n' || c == '\r')
 2e6:	01578763          	beq	a5,s5,2f4 <gets+0x54>
 2ea:	0905                	addi	s2,s2,1
 2ec:	fd679be3          	bne	a5,s6,2c2 <gets+0x22>
  for(i=0; i+1 < max; ){
 2f0:	89a6                	mv	s3,s1
 2f2:	a011                	j	2f6 <gets+0x56>
 2f4:	89a6                	mv	s3,s1
      break;
  }
  buf[i] = '\0';
 2f6:	99de                	add	s3,s3,s7
 2f8:	00098023          	sb	zero,0(s3)
  return buf;
}
 2fc:	855e                	mv	a0,s7
 2fe:	60e6                	ld	ra,88(sp)
 300:	6446                	ld	s0,80(sp)
 302:	64a6                	ld	s1,72(sp)
 304:	6906                	ld	s2,64(sp)
 306:	79e2                	ld	s3,56(sp)
 308:	7a42                	ld	s4,48(sp)
 30a:	7aa2                	ld	s5,40(sp)
 30c:	7b02                	ld	s6,32(sp)
 30e:	6be2                	ld	s7,24(sp)
 310:	6125                	addi	sp,sp,96
 312:	8082                	ret

0000000000000314 <stat>:

int
stat(const char *n, struct stat *st)
{
 314:	1101                	addi	sp,sp,-32
 316:	ec06                	sd	ra,24(sp)
 318:	e822                	sd	s0,16(sp)
 31a:	e426                	sd	s1,8(sp)
 31c:	e04a                	sd	s2,0(sp)
 31e:	1000                	addi	s0,sp,32
 320:	892e                	mv	s2,a1
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 322:	4581                	li	a1,0
 324:	00000097          	auipc	ra,0x0
 328:	176080e7          	jalr	374(ra) # 49a <open>
  if(fd < 0)
 32c:	02054563          	bltz	a0,356 <stat+0x42>
 330:	84aa                	mv	s1,a0
    return -1;
  r = fstat(fd, st);
 332:	85ca                	mv	a1,s2
 334:	00000097          	auipc	ra,0x0
 338:	17e080e7          	jalr	382(ra) # 4b2 <fstat>
 33c:	892a                	mv	s2,a0
  close(fd);
 33e:	8526                	mv	a0,s1
 340:	00000097          	auipc	ra,0x0
 344:	142080e7          	jalr	322(ra) # 482 <close>
  return r;
}
 348:	854a                	mv	a0,s2
 34a:	60e2                	ld	ra,24(sp)
 34c:	6442                	ld	s0,16(sp)
 34e:	64a2                	ld	s1,8(sp)
 350:	6902                	ld	s2,0(sp)
 352:	6105                	addi	sp,sp,32
 354:	8082                	ret
    return -1;
 356:	597d                	li	s2,-1
 358:	bfc5                	j	348 <stat+0x34>

000000000000035a <atoi>:

int
atoi(const char *s)
{
 35a:	1141                	addi	sp,sp,-16
 35c:	e422                	sd	s0,8(sp)
 35e:	0800                	addi	s0,sp,16
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 360:	00054603          	lbu	a2,0(a0)
 364:	fd06079b          	addiw	a5,a2,-48
 368:	0ff7f793          	andi	a5,a5,255
 36c:	4725                	li	a4,9
 36e:	02f76963          	bltu	a4,a5,3a0 <atoi+0x46>
 372:	86aa                	mv	a3,a0
  n = 0;
 374:	4501                	li	a0,0
  while('0' <= *s && *s <= '9')
 376:	45a5                	li	a1,9
    n = n*10 + *s++ - '0';
 378:	0685                	addi	a3,a3,1
 37a:	0025179b          	slliw	a5,a0,0x2
 37e:	9fa9                	addw	a5,a5,a0
 380:	0017979b          	slliw	a5,a5,0x1
 384:	9fb1                	addw	a5,a5,a2
 386:	fd07851b          	addiw	a0,a5,-48
  while('0' <= *s && *s <= '9')
 38a:	0006c603          	lbu	a2,0(a3)
 38e:	fd06071b          	addiw	a4,a2,-48
 392:	0ff77713          	andi	a4,a4,255
 396:	fee5f1e3          	bgeu	a1,a4,378 <atoi+0x1e>
  return n;
}
 39a:	6422                	ld	s0,8(sp)
 39c:	0141                	addi	sp,sp,16
 39e:	8082                	ret
  n = 0;
 3a0:	4501                	li	a0,0
 3a2:	bfe5                	j	39a <atoi+0x40>

00000000000003a4 <memmove>:

void*
memmove(void *vdst, const void *vsrc, int n)
{
 3a4:	1141                	addi	sp,sp,-16
 3a6:	e422                	sd	s0,8(sp)
 3a8:	0800                	addi	s0,sp,16
  char *dst;
  const char *src;

  dst = vdst;
  src = vsrc;
  if (src > dst) {
 3aa:	02b57663          	bgeu	a0,a1,3d6 <memmove+0x32>
    while(n-- > 0)
 3ae:	02c05163          	blez	a2,3d0 <memmove+0x2c>
 3b2:	fff6079b          	addiw	a5,a2,-1
 3b6:	1782                	slli	a5,a5,0x20
 3b8:	9381                	srli	a5,a5,0x20
 3ba:	0785                	addi	a5,a5,1
 3bc:	97aa                	add	a5,a5,a0
  dst = vdst;
 3be:	872a                	mv	a4,a0
      *dst++ = *src++;
 3c0:	0585                	addi	a1,a1,1
 3c2:	0705                	addi	a4,a4,1
 3c4:	fff5c683          	lbu	a3,-1(a1)
 3c8:	fed70fa3          	sb	a3,-1(a4)
    while(n-- > 0)
 3cc:	fee79ae3          	bne	a5,a4,3c0 <memmove+0x1c>
    src += n;
    while(n-- > 0)
      *--dst = *--src;
  }
  return vdst;
}
 3d0:	6422                	ld	s0,8(sp)
 3d2:	0141                	addi	sp,sp,16
 3d4:	8082                	ret
    dst += n;
 3d6:	00c50733          	add	a4,a0,a2
    src += n;
 3da:	95b2                	add	a1,a1,a2
    while(n-- > 0)
 3dc:	fec05ae3          	blez	a2,3d0 <memmove+0x2c>
 3e0:	fff6079b          	addiw	a5,a2,-1
 3e4:	1782                	slli	a5,a5,0x20
 3e6:	9381                	srli	a5,a5,0x20
 3e8:	fff7c793          	not	a5,a5
 3ec:	97ba                	add	a5,a5,a4
      *--dst = *--src;
 3ee:	15fd                	addi	a1,a1,-1
 3f0:	177d                	addi	a4,a4,-1
 3f2:	0005c683          	lbu	a3,0(a1)
 3f6:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
 3fa:	fee79ae3          	bne	a5,a4,3ee <memmove+0x4a>
 3fe:	bfc9                	j	3d0 <memmove+0x2c>

0000000000000400 <memcmp>:

int
memcmp(const void *s1, const void *s2, uint n)
{
 400:	1141                	addi	sp,sp,-16
 402:	e422                	sd	s0,8(sp)
 404:	0800                	addi	s0,sp,16
  const char *p1 = s1, *p2 = s2;
  while (n-- > 0) {
 406:	ca05                	beqz	a2,436 <memcmp+0x36>
 408:	fff6069b          	addiw	a3,a2,-1
 40c:	1682                	slli	a3,a3,0x20
 40e:	9281                	srli	a3,a3,0x20
 410:	0685                	addi	a3,a3,1
 412:	96aa                	add	a3,a3,a0
    if (*p1 != *p2) {
 414:	00054783          	lbu	a5,0(a0)
 418:	0005c703          	lbu	a4,0(a1)
 41c:	00e79863          	bne	a5,a4,42c <memcmp+0x2c>
      return *p1 - *p2;
    }
    p1++;
 420:	0505                	addi	a0,a0,1
    p2++;
 422:	0585                	addi	a1,a1,1
  while (n-- > 0) {
 424:	fed518e3          	bne	a0,a3,414 <memcmp+0x14>
  }
  return 0;
 428:	4501                	li	a0,0
 42a:	a019                	j	430 <memcmp+0x30>
      return *p1 - *p2;
 42c:	40e7853b          	subw	a0,a5,a4
}
 430:	6422                	ld	s0,8(sp)
 432:	0141                	addi	sp,sp,16
 434:	8082                	ret
  return 0;
 436:	4501                	li	a0,0
 438:	bfe5                	j	430 <memcmp+0x30>

000000000000043a <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
 43a:	1141                	addi	sp,sp,-16
 43c:	e406                	sd	ra,8(sp)
 43e:	e022                	sd	s0,0(sp)
 440:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
 442:	00000097          	auipc	ra,0x0
 446:	f62080e7          	jalr	-158(ra) # 3a4 <memmove>
}
 44a:	60a2                	ld	ra,8(sp)
 44c:	6402                	ld	s0,0(sp)
 44e:	0141                	addi	sp,sp,16
 450:	8082                	ret

0000000000000452 <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
 li a7, SYS_fork
 452:	4885                	li	a7,1
 ecall
 454:	00000073          	ecall
 ret
 458:	8082                	ret

000000000000045a <exit>:
.global exit
exit:
 li a7, SYS_exit
 45a:	4889                	li	a7,2
 ecall
 45c:	00000073          	ecall
 ret
 460:	8082                	ret

0000000000000462 <wait>:
.global wait
wait:
 li a7, SYS_wait
 462:	488d                	li	a7,3
 ecall
 464:	00000073          	ecall
 ret
 468:	8082                	ret

000000000000046a <pipe>:
.global pipe
pipe:
 li a7, SYS_pipe
 46a:	4891                	li	a7,4
 ecall
 46c:	00000073          	ecall
 ret
 470:	8082                	ret

0000000000000472 <read>:
.global read
read:
 li a7, SYS_read
 472:	4895                	li	a7,5
 ecall
 474:	00000073          	ecall
 ret
 478:	8082                	ret

000000000000047a <write>:
.global write
write:
 li a7, SYS_write
 47a:	48c1                	li	a7,16
 ecall
 47c:	00000073          	ecall
 ret
 480:	8082                	ret

0000000000000482 <close>:
.global close
close:
 li a7, SYS_close
 482:	48d5                	li	a7,21
 ecall
 484:	00000073          	ecall
 ret
 488:	8082                	ret

000000000000048a <kill>:
.global kill
kill:
 li a7, SYS_kill
 48a:	4899                	li	a7,6
 ecall
 48c:	00000073          	ecall
 ret
 490:	8082                	ret

0000000000000492 <exec>:
.global exec
exec:
 li a7, SYS_exec
 492:	489d                	li	a7,7
 ecall
 494:	00000073          	ecall
 ret
 498:	8082                	ret

000000000000049a <open>:
.global open
open:
 li a7, SYS_open
 49a:	48bd                	li	a7,15
 ecall
 49c:	00000073          	ecall
 ret
 4a0:	8082                	ret

00000000000004a2 <mknod>:
.global mknod
mknod:
 li a7, SYS_mknod
 4a2:	48c5                	li	a7,17
 ecall
 4a4:	00000073          	ecall
 ret
 4a8:	8082                	ret

00000000000004aa <unlink>:
.global unlink
unlink:
 li a7, SYS_unlink
 4aa:	48c9                	li	a7,18
 ecall
 4ac:	00000073          	ecall
 ret
 4b0:	8082                	ret

00000000000004b2 <fstat>:
.global fstat
fstat:
 li a7, SYS_fstat
 4b2:	48a1                	li	a7,8
 ecall
 4b4:	00000073          	ecall
 ret
 4b8:	8082                	ret

00000000000004ba <link>:
.global link
link:
 li a7, SYS_link
 4ba:	48cd                	li	a7,19
 ecall
 4bc:	00000073          	ecall
 ret
 4c0:	8082                	ret

00000000000004c2 <mkdir>:
.global mkdir
mkdir:
 li a7, SYS_mkdir
 4c2:	48d1                	li	a7,20
 ecall
 4c4:	00000073          	ecall
 ret
 4c8:	8082                	ret

00000000000004ca <chdir>:
.global chdir
chdir:
 li a7, SYS_chdir
 4ca:	48a5                	li	a7,9
 ecall
 4cc:	00000073          	ecall
 ret
 4d0:	8082                	ret

00000000000004d2 <dup>:
.global dup
dup:
 li a7, SYS_dup
 4d2:	48a9                	li	a7,10
 ecall
 4d4:	00000073          	ecall
 ret
 4d8:	8082                	ret

00000000000004da <getpid>:
.global getpid
getpid:
 li a7, SYS_getpid
 4da:	48ad                	li	a7,11
 ecall
 4dc:	00000073          	ecall
 ret
 4e0:	8082                	ret

00000000000004e2 <sbrk>:
.global sbrk
sbrk:
 li a7, SYS_sbrk
 4e2:	48b1                	li	a7,12
 ecall
 4e4:	00000073          	ecall
 ret
 4e8:	8082                	ret

00000000000004ea <sleep>:
.global sleep
sleep:
 li a7, SYS_sleep
 4ea:	48b5                	li	a7,13
 ecall
 4ec:	00000073          	ecall
 ret
 4f0:	8082                	ret

00000000000004f2 <uptime>:
.global uptime
uptime:
 li a7, SYS_uptime
 4f2:	48b9                	li	a7,14
 ecall
 4f4:	00000073          	ecall
 ret
 4f8:	8082                	ret

00000000000004fa <putc>:

static char digits[] = "0123456789ABCDEF";

static void
putc(int fd, char c)
{
 4fa:	1101                	addi	sp,sp,-32
 4fc:	ec06                	sd	ra,24(sp)
 4fe:	e822                	sd	s0,16(sp)
 500:	1000                	addi	s0,sp,32
 502:	feb407a3          	sb	a1,-17(s0)
  write(fd, &c, 1);
 506:	4605                	li	a2,1
 508:	fef40593          	addi	a1,s0,-17
 50c:	00000097          	auipc	ra,0x0
 510:	f6e080e7          	jalr	-146(ra) # 47a <write>
}
 514:	60e2                	ld	ra,24(sp)
 516:	6442                	ld	s0,16(sp)
 518:	6105                	addi	sp,sp,32
 51a:	8082                	ret

000000000000051c <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 51c:	7139                	addi	sp,sp,-64
 51e:	fc06                	sd	ra,56(sp)
 520:	f822                	sd	s0,48(sp)
 522:	f426                	sd	s1,40(sp)
 524:	f04a                	sd	s2,32(sp)
 526:	ec4e                	sd	s3,24(sp)
 528:	0080                	addi	s0,sp,64
 52a:	84aa                	mv	s1,a0
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 52c:	c299                	beqz	a3,532 <printint+0x16>
 52e:	0805c863          	bltz	a1,5be <printint+0xa2>
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 532:	2581                	sext.w	a1,a1
  neg = 0;
 534:	4881                	li	a7,0
 536:	fc040693          	addi	a3,s0,-64
  }

  i = 0;
 53a:	4701                	li	a4,0
  do{
    buf[i++] = digits[x % base];
 53c:	2601                	sext.w	a2,a2
 53e:	00000517          	auipc	a0,0x0
 542:	4d250513          	addi	a0,a0,1234 # a10 <digits>
 546:	883a                	mv	a6,a4
 548:	2705                	addiw	a4,a4,1
 54a:	02c5f7bb          	remuw	a5,a1,a2
 54e:	1782                	slli	a5,a5,0x20
 550:	9381                	srli	a5,a5,0x20
 552:	97aa                	add	a5,a5,a0
 554:	0007c783          	lbu	a5,0(a5)
 558:	00f68023          	sb	a5,0(a3)
  }while((x /= base) != 0);
 55c:	0005879b          	sext.w	a5,a1
 560:	02c5d5bb          	divuw	a1,a1,a2
 564:	0685                	addi	a3,a3,1
 566:	fec7f0e3          	bgeu	a5,a2,546 <printint+0x2a>
  if(neg)
 56a:	00088b63          	beqz	a7,580 <printint+0x64>
    buf[i++] = '-';
 56e:	fd040793          	addi	a5,s0,-48
 572:	973e                	add	a4,a4,a5
 574:	02d00793          	li	a5,45
 578:	fef70823          	sb	a5,-16(a4)
 57c:	0028071b          	addiw	a4,a6,2

  while(--i >= 0)
 580:	02e05863          	blez	a4,5b0 <printint+0x94>
 584:	fc040793          	addi	a5,s0,-64
 588:	00e78933          	add	s2,a5,a4
 58c:	fff78993          	addi	s3,a5,-1
 590:	99ba                	add	s3,s3,a4
 592:	377d                	addiw	a4,a4,-1
 594:	1702                	slli	a4,a4,0x20
 596:	9301                	srli	a4,a4,0x20
 598:	40e989b3          	sub	s3,s3,a4
    putc(fd, buf[i]);
 59c:	fff94583          	lbu	a1,-1(s2)
 5a0:	8526                	mv	a0,s1
 5a2:	00000097          	auipc	ra,0x0
 5a6:	f58080e7          	jalr	-168(ra) # 4fa <putc>
  while(--i >= 0)
 5aa:	197d                	addi	s2,s2,-1
 5ac:	ff3918e3          	bne	s2,s3,59c <printint+0x80>
}
 5b0:	70e2                	ld	ra,56(sp)
 5b2:	7442                	ld	s0,48(sp)
 5b4:	74a2                	ld	s1,40(sp)
 5b6:	7902                	ld	s2,32(sp)
 5b8:	69e2                	ld	s3,24(sp)
 5ba:	6121                	addi	sp,sp,64
 5bc:	8082                	ret
    x = -xx;
 5be:	40b005bb          	negw	a1,a1
    neg = 1;
 5c2:	4885                	li	a7,1
    x = -xx;
 5c4:	bf8d                	j	536 <printint+0x1a>

00000000000005c6 <vprintf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
 5c6:	7119                	addi	sp,sp,-128
 5c8:	fc86                	sd	ra,120(sp)
 5ca:	f8a2                	sd	s0,112(sp)
 5cc:	f4a6                	sd	s1,104(sp)
 5ce:	f0ca                	sd	s2,96(sp)
 5d0:	ecce                	sd	s3,88(sp)
 5d2:	e8d2                	sd	s4,80(sp)
 5d4:	e4d6                	sd	s5,72(sp)
 5d6:	e0da                	sd	s6,64(sp)
 5d8:	fc5e                	sd	s7,56(sp)
 5da:	f862                	sd	s8,48(sp)
 5dc:	f466                	sd	s9,40(sp)
 5de:	f06a                	sd	s10,32(sp)
 5e0:	ec6e                	sd	s11,24(sp)
 5e2:	0100                	addi	s0,sp,128
  char *s;
  int c, i, state;

  state = 0;
  for(i = 0; fmt[i]; i++){
 5e4:	0005c903          	lbu	s2,0(a1)
 5e8:	18090f63          	beqz	s2,786 <vprintf+0x1c0>
 5ec:	8aaa                	mv	s5,a0
 5ee:	8b32                	mv	s6,a2
 5f0:	00158493          	addi	s1,a1,1
  state = 0;
 5f4:	4981                	li	s3,0
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 5f6:	02500a13          	li	s4,37
      if(c == 'd'){
 5fa:	06400c13          	li	s8,100
        printint(fd, va_arg(ap, int), 10, 1);
      } else if(c == 'l') {
 5fe:	06c00c93          	li	s9,108
        printint(fd, va_arg(ap, uint64), 10, 0);
      } else if(c == 'x') {
 602:	07800d13          	li	s10,120
        printint(fd, va_arg(ap, int), 16, 0);
      } else if(c == 'p') {
 606:	07000d93          	li	s11,112
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 60a:	00000b97          	auipc	s7,0x0
 60e:	406b8b93          	addi	s7,s7,1030 # a10 <digits>
 612:	a839                	j	630 <vprintf+0x6a>
        putc(fd, c);
 614:	85ca                	mv	a1,s2
 616:	8556                	mv	a0,s5
 618:	00000097          	auipc	ra,0x0
 61c:	ee2080e7          	jalr	-286(ra) # 4fa <putc>
 620:	a019                	j	626 <vprintf+0x60>
    } else if(state == '%'){
 622:	01498f63          	beq	s3,s4,640 <vprintf+0x7a>
  for(i = 0; fmt[i]; i++){
 626:	0485                	addi	s1,s1,1
 628:	fff4c903          	lbu	s2,-1(s1)
 62c:	14090d63          	beqz	s2,786 <vprintf+0x1c0>
    c = fmt[i] & 0xff;
 630:	0009079b          	sext.w	a5,s2
    if(state == 0){
 634:	fe0997e3          	bnez	s3,622 <vprintf+0x5c>
      if(c == '%'){
 638:	fd479ee3          	bne	a5,s4,614 <vprintf+0x4e>
        state = '%';
 63c:	89be                	mv	s3,a5
 63e:	b7e5                	j	626 <vprintf+0x60>
      if(c == 'd'){
 640:	05878063          	beq	a5,s8,680 <vprintf+0xba>
      } else if(c == 'l') {
 644:	05978c63          	beq	a5,s9,69c <vprintf+0xd6>
      } else if(c == 'x') {
 648:	07a78863          	beq	a5,s10,6b8 <vprintf+0xf2>
      } else if(c == 'p') {
 64c:	09b78463          	beq	a5,s11,6d4 <vprintf+0x10e>
        printptr(fd, va_arg(ap, uint64));
      } else if(c == 's'){
 650:	07300713          	li	a4,115
 654:	0ce78663          	beq	a5,a4,720 <vprintf+0x15a>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 658:	06300713          	li	a4,99
 65c:	0ee78e63          	beq	a5,a4,758 <vprintf+0x192>
        putc(fd, va_arg(ap, uint));
      } else if(c == '%'){
 660:	11478863          	beq	a5,s4,770 <vprintf+0x1aa>
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
 664:	85d2                	mv	a1,s4
 666:	8556                	mv	a0,s5
 668:	00000097          	auipc	ra,0x0
 66c:	e92080e7          	jalr	-366(ra) # 4fa <putc>
        putc(fd, c);
 670:	85ca                	mv	a1,s2
 672:	8556                	mv	a0,s5
 674:	00000097          	auipc	ra,0x0
 678:	e86080e7          	jalr	-378(ra) # 4fa <putc>
      }
      state = 0;
 67c:	4981                	li	s3,0
 67e:	b765                	j	626 <vprintf+0x60>
        printint(fd, va_arg(ap, int), 10, 1);
 680:	008b0913          	addi	s2,s6,8
 684:	4685                	li	a3,1
 686:	4629                	li	a2,10
 688:	000b2583          	lw	a1,0(s6)
 68c:	8556                	mv	a0,s5
 68e:	00000097          	auipc	ra,0x0
 692:	e8e080e7          	jalr	-370(ra) # 51c <printint>
 696:	8b4a                	mv	s6,s2
      state = 0;
 698:	4981                	li	s3,0
 69a:	b771                	j	626 <vprintf+0x60>
        printint(fd, va_arg(ap, uint64), 10, 0);
 69c:	008b0913          	addi	s2,s6,8
 6a0:	4681                	li	a3,0
 6a2:	4629                	li	a2,10
 6a4:	000b2583          	lw	a1,0(s6)
 6a8:	8556                	mv	a0,s5
 6aa:	00000097          	auipc	ra,0x0
 6ae:	e72080e7          	jalr	-398(ra) # 51c <printint>
 6b2:	8b4a                	mv	s6,s2
      state = 0;
 6b4:	4981                	li	s3,0
 6b6:	bf85                	j	626 <vprintf+0x60>
        printint(fd, va_arg(ap, int), 16, 0);
 6b8:	008b0913          	addi	s2,s6,8
 6bc:	4681                	li	a3,0
 6be:	4641                	li	a2,16
 6c0:	000b2583          	lw	a1,0(s6)
 6c4:	8556                	mv	a0,s5
 6c6:	00000097          	auipc	ra,0x0
 6ca:	e56080e7          	jalr	-426(ra) # 51c <printint>
 6ce:	8b4a                	mv	s6,s2
      state = 0;
 6d0:	4981                	li	s3,0
 6d2:	bf91                	j	626 <vprintf+0x60>
        printptr(fd, va_arg(ap, uint64));
 6d4:	008b0793          	addi	a5,s6,8
 6d8:	f8f43423          	sd	a5,-120(s0)
 6dc:	000b3983          	ld	s3,0(s6)
  putc(fd, '0');
 6e0:	03000593          	li	a1,48
 6e4:	8556                	mv	a0,s5
 6e6:	00000097          	auipc	ra,0x0
 6ea:	e14080e7          	jalr	-492(ra) # 4fa <putc>
  putc(fd, 'x');
 6ee:	85ea                	mv	a1,s10
 6f0:	8556                	mv	a0,s5
 6f2:	00000097          	auipc	ra,0x0
 6f6:	e08080e7          	jalr	-504(ra) # 4fa <putc>
 6fa:	4941                	li	s2,16
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 6fc:	03c9d793          	srli	a5,s3,0x3c
 700:	97de                	add	a5,a5,s7
 702:	0007c583          	lbu	a1,0(a5)
 706:	8556                	mv	a0,s5
 708:	00000097          	auipc	ra,0x0
 70c:	df2080e7          	jalr	-526(ra) # 4fa <putc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
 710:	0992                	slli	s3,s3,0x4
 712:	397d                	addiw	s2,s2,-1
 714:	fe0914e3          	bnez	s2,6fc <vprintf+0x136>
        printptr(fd, va_arg(ap, uint64));
 718:	f8843b03          	ld	s6,-120(s0)
      state = 0;
 71c:	4981                	li	s3,0
 71e:	b721                	j	626 <vprintf+0x60>
        s = va_arg(ap, char*);
 720:	008b0993          	addi	s3,s6,8
 724:	000b3903          	ld	s2,0(s6)
        if(s == 0)
 728:	02090163          	beqz	s2,74a <vprintf+0x184>
        while(*s != 0){
 72c:	00094583          	lbu	a1,0(s2)
 730:	c9a1                	beqz	a1,780 <vprintf+0x1ba>
          putc(fd, *s);
 732:	8556                	mv	a0,s5
 734:	00000097          	auipc	ra,0x0
 738:	dc6080e7          	jalr	-570(ra) # 4fa <putc>
          s++;
 73c:	0905                	addi	s2,s2,1
        while(*s != 0){
 73e:	00094583          	lbu	a1,0(s2)
 742:	f9e5                	bnez	a1,732 <vprintf+0x16c>
        s = va_arg(ap, char*);
 744:	8b4e                	mv	s6,s3
      state = 0;
 746:	4981                	li	s3,0
 748:	bdf9                	j	626 <vprintf+0x60>
          s = "(null)";
 74a:	00000917          	auipc	s2,0x0
 74e:	2be90913          	addi	s2,s2,702 # a08 <malloc+0x178>
        while(*s != 0){
 752:	02800593          	li	a1,40
 756:	bff1                	j	732 <vprintf+0x16c>
        putc(fd, va_arg(ap, uint));
 758:	008b0913          	addi	s2,s6,8
 75c:	000b4583          	lbu	a1,0(s6)
 760:	8556                	mv	a0,s5
 762:	00000097          	auipc	ra,0x0
 766:	d98080e7          	jalr	-616(ra) # 4fa <putc>
 76a:	8b4a                	mv	s6,s2
      state = 0;
 76c:	4981                	li	s3,0
 76e:	bd65                	j	626 <vprintf+0x60>
        putc(fd, c);
 770:	85d2                	mv	a1,s4
 772:	8556                	mv	a0,s5
 774:	00000097          	auipc	ra,0x0
 778:	d86080e7          	jalr	-634(ra) # 4fa <putc>
      state = 0;
 77c:	4981                	li	s3,0
 77e:	b565                	j	626 <vprintf+0x60>
        s = va_arg(ap, char*);
 780:	8b4e                	mv	s6,s3
      state = 0;
 782:	4981                	li	s3,0
 784:	b54d                	j	626 <vprintf+0x60>
    }
  }
}
 786:	70e6                	ld	ra,120(sp)
 788:	7446                	ld	s0,112(sp)
 78a:	74a6                	ld	s1,104(sp)
 78c:	7906                	ld	s2,96(sp)
 78e:	69e6                	ld	s3,88(sp)
 790:	6a46                	ld	s4,80(sp)
 792:	6aa6                	ld	s5,72(sp)
 794:	6b06                	ld	s6,64(sp)
 796:	7be2                	ld	s7,56(sp)
 798:	7c42                	ld	s8,48(sp)
 79a:	7ca2                	ld	s9,40(sp)
 79c:	7d02                	ld	s10,32(sp)
 79e:	6de2                	ld	s11,24(sp)
 7a0:	6109                	addi	sp,sp,128
 7a2:	8082                	ret

00000000000007a4 <fprintf>:

void
fprintf(int fd, const char *fmt, ...)
{
 7a4:	715d                	addi	sp,sp,-80
 7a6:	ec06                	sd	ra,24(sp)
 7a8:	e822                	sd	s0,16(sp)
 7aa:	1000                	addi	s0,sp,32
 7ac:	e010                	sd	a2,0(s0)
 7ae:	e414                	sd	a3,8(s0)
 7b0:	e818                	sd	a4,16(s0)
 7b2:	ec1c                	sd	a5,24(s0)
 7b4:	03043023          	sd	a6,32(s0)
 7b8:	03143423          	sd	a7,40(s0)
  va_list ap;

  va_start(ap, fmt);
 7bc:	fe843423          	sd	s0,-24(s0)
  vprintf(fd, fmt, ap);
 7c0:	8622                	mv	a2,s0
 7c2:	00000097          	auipc	ra,0x0
 7c6:	e04080e7          	jalr	-508(ra) # 5c6 <vprintf>
}
 7ca:	60e2                	ld	ra,24(sp)
 7cc:	6442                	ld	s0,16(sp)
 7ce:	6161                	addi	sp,sp,80
 7d0:	8082                	ret

00000000000007d2 <printf>:

void
printf(const char *fmt, ...)
{
 7d2:	711d                	addi	sp,sp,-96
 7d4:	ec06                	sd	ra,24(sp)
 7d6:	e822                	sd	s0,16(sp)
 7d8:	1000                	addi	s0,sp,32
 7da:	e40c                	sd	a1,8(s0)
 7dc:	e810                	sd	a2,16(s0)
 7de:	ec14                	sd	a3,24(s0)
 7e0:	f018                	sd	a4,32(s0)
 7e2:	f41c                	sd	a5,40(s0)
 7e4:	03043823          	sd	a6,48(s0)
 7e8:	03143c23          	sd	a7,56(s0)
  va_list ap;

  va_start(ap, fmt);
 7ec:	00840613          	addi	a2,s0,8
 7f0:	fec43423          	sd	a2,-24(s0)
  vprintf(1, fmt, ap);
 7f4:	85aa                	mv	a1,a0
 7f6:	4505                	li	a0,1
 7f8:	00000097          	auipc	ra,0x0
 7fc:	dce080e7          	jalr	-562(ra) # 5c6 <vprintf>
}
 800:	60e2                	ld	ra,24(sp)
 802:	6442                	ld	s0,16(sp)
 804:	6125                	addi	sp,sp,96
 806:	8082                	ret

0000000000000808 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 808:	1141                	addi	sp,sp,-16
 80a:	e422                	sd	s0,8(sp)
 80c:	0800                	addi	s0,sp,16
  Header *bp, *p;

  bp = (Header*)ap - 1;
 80e:	ff050693          	addi	a3,a0,-16
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 812:	00000797          	auipc	a5,0x0
 816:	2167b783          	ld	a5,534(a5) # a28 <freep>
 81a:	a805                	j	84a <free+0x42>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 81c:	4618                	lw	a4,8(a2)
 81e:	9db9                	addw	a1,a1,a4
 820:	feb52c23          	sw	a1,-8(a0)
    bp->s.ptr = p->s.ptr->s.ptr;
 824:	6398                	ld	a4,0(a5)
 826:	6318                	ld	a4,0(a4)
 828:	fee53823          	sd	a4,-16(a0)
 82c:	a091                	j	870 <free+0x68>
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
 82e:	ff852703          	lw	a4,-8(a0)
 832:	9e39                	addw	a2,a2,a4
 834:	c790                	sw	a2,8(a5)
    p->s.ptr = bp->s.ptr;
 836:	ff053703          	ld	a4,-16(a0)
 83a:	e398                	sd	a4,0(a5)
 83c:	a099                	j	882 <free+0x7a>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 83e:	6398                	ld	a4,0(a5)
 840:	00e7e463          	bltu	a5,a4,848 <free+0x40>
 844:	00e6ea63          	bltu	a3,a4,858 <free+0x50>
{
 848:	87ba                	mv	a5,a4
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 84a:	fed7fae3          	bgeu	a5,a3,83e <free+0x36>
 84e:	6398                	ld	a4,0(a5)
 850:	00e6e463          	bltu	a3,a4,858 <free+0x50>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 854:	fee7eae3          	bltu	a5,a4,848 <free+0x40>
  if(bp + bp->s.size == p->s.ptr){
 858:	ff852583          	lw	a1,-8(a0)
 85c:	6390                	ld	a2,0(a5)
 85e:	02059713          	slli	a4,a1,0x20
 862:	9301                	srli	a4,a4,0x20
 864:	0712                	slli	a4,a4,0x4
 866:	9736                	add	a4,a4,a3
 868:	fae60ae3          	beq	a2,a4,81c <free+0x14>
    bp->s.ptr = p->s.ptr;
 86c:	fec53823          	sd	a2,-16(a0)
  if(p + p->s.size == bp){
 870:	4790                	lw	a2,8(a5)
 872:	02061713          	slli	a4,a2,0x20
 876:	9301                	srli	a4,a4,0x20
 878:	0712                	slli	a4,a4,0x4
 87a:	973e                	add	a4,a4,a5
 87c:	fae689e3          	beq	a3,a4,82e <free+0x26>
  } else
    p->s.ptr = bp;
 880:	e394                	sd	a3,0(a5)
  freep = p;
 882:	00000717          	auipc	a4,0x0
 886:	1af73323          	sd	a5,422(a4) # a28 <freep>
}
 88a:	6422                	ld	s0,8(sp)
 88c:	0141                	addi	sp,sp,16
 88e:	8082                	ret

0000000000000890 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
 890:	7139                	addi	sp,sp,-64
 892:	fc06                	sd	ra,56(sp)
 894:	f822                	sd	s0,48(sp)
 896:	f426                	sd	s1,40(sp)
 898:	f04a                	sd	s2,32(sp)
 89a:	ec4e                	sd	s3,24(sp)
 89c:	e852                	sd	s4,16(sp)
 89e:	e456                	sd	s5,8(sp)
 8a0:	e05a                	sd	s6,0(sp)
 8a2:	0080                	addi	s0,sp,64
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 8a4:	02051493          	slli	s1,a0,0x20
 8a8:	9081                	srli	s1,s1,0x20
 8aa:	04bd                	addi	s1,s1,15
 8ac:	8091                	srli	s1,s1,0x4
 8ae:	0014899b          	addiw	s3,s1,1
 8b2:	0485                	addi	s1,s1,1
  if((prevp = freep) == 0){
 8b4:	00000517          	auipc	a0,0x0
 8b8:	17453503          	ld	a0,372(a0) # a28 <freep>
 8bc:	c515                	beqz	a0,8e8 <malloc+0x58>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 8be:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 8c0:	4798                	lw	a4,8(a5)
 8c2:	02977f63          	bgeu	a4,s1,900 <malloc+0x70>
 8c6:	8a4e                	mv	s4,s3
 8c8:	0009871b          	sext.w	a4,s3
 8cc:	6685                	lui	a3,0x1
 8ce:	00d77363          	bgeu	a4,a3,8d4 <malloc+0x44>
 8d2:	6a05                	lui	s4,0x1
 8d4:	000a0b1b          	sext.w	s6,s4
  p = sbrk(nu * sizeof(Header));
 8d8:	004a1a1b          	slliw	s4,s4,0x4
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*)(p + 1);
    }
    if(p == freep)
 8dc:	00000917          	auipc	s2,0x0
 8e0:	14c90913          	addi	s2,s2,332 # a28 <freep>
  if(p == (char*)-1)
 8e4:	5afd                	li	s5,-1
 8e6:	a88d                	j	958 <malloc+0xc8>
    base.s.ptr = freep = prevp = &base;
 8e8:	00000797          	auipc	a5,0x0
 8ec:	14878793          	addi	a5,a5,328 # a30 <base>
 8f0:	00000717          	auipc	a4,0x0
 8f4:	12f73c23          	sd	a5,312(a4) # a28 <freep>
 8f8:	e39c                	sd	a5,0(a5)
    base.s.size = 0;
 8fa:	0007a423          	sw	zero,8(a5)
    if(p->s.size >= nunits){
 8fe:	b7e1                	j	8c6 <malloc+0x36>
      if(p->s.size == nunits)
 900:	02e48b63          	beq	s1,a4,936 <malloc+0xa6>
        p->s.size -= nunits;
 904:	4137073b          	subw	a4,a4,s3
 908:	c798                	sw	a4,8(a5)
        p += p->s.size;
 90a:	1702                	slli	a4,a4,0x20
 90c:	9301                	srli	a4,a4,0x20
 90e:	0712                	slli	a4,a4,0x4
 910:	97ba                	add	a5,a5,a4
        p->s.size = nunits;
 912:	0137a423          	sw	s3,8(a5)
      freep = prevp;
 916:	00000717          	auipc	a4,0x0
 91a:	10a73923          	sd	a0,274(a4) # a28 <freep>
      return (void*)(p + 1);
 91e:	01078513          	addi	a0,a5,16
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 922:	70e2                	ld	ra,56(sp)
 924:	7442                	ld	s0,48(sp)
 926:	74a2                	ld	s1,40(sp)
 928:	7902                	ld	s2,32(sp)
 92a:	69e2                	ld	s3,24(sp)
 92c:	6a42                	ld	s4,16(sp)
 92e:	6aa2                	ld	s5,8(sp)
 930:	6b02                	ld	s6,0(sp)
 932:	6121                	addi	sp,sp,64
 934:	8082                	ret
        prevp->s.ptr = p->s.ptr;
 936:	6398                	ld	a4,0(a5)
 938:	e118                	sd	a4,0(a0)
 93a:	bff1                	j	916 <malloc+0x86>
  hp->s.size = nu;
 93c:	01652423          	sw	s6,8(a0)
  free((void*)(hp + 1));
 940:	0541                	addi	a0,a0,16
 942:	00000097          	auipc	ra,0x0
 946:	ec6080e7          	jalr	-314(ra) # 808 <free>
  return freep;
 94a:	00093503          	ld	a0,0(s2)
      if((p = morecore(nunits)) == 0)
 94e:	d971                	beqz	a0,922 <malloc+0x92>
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 950:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 952:	4798                	lw	a4,8(a5)
 954:	fa9776e3          	bgeu	a4,s1,900 <malloc+0x70>
    if(p == freep)
 958:	00093703          	ld	a4,0(s2)
 95c:	853e                	mv	a0,a5
 95e:	fef719e3          	bne	a4,a5,950 <malloc+0xc0>
  p = sbrk(nu * sizeof(Header));
 962:	8552                	mv	a0,s4
 964:	00000097          	auipc	ra,0x0
 968:	b7e080e7          	jalr	-1154(ra) # 4e2 <sbrk>
  if(p == (char*)-1)
 96c:	fd5518e3          	bne	a0,s5,93c <malloc+0xac>
        return 0;
 970:	4501                	li	a0,0
 972:	bf45                	j	922 <malloc+0x92>
